<html>  
<head>  
    <title>导入</title>  
  
    <link href="../css/bootstrap/bootstrap.css" rel="stylesheet">  
    <link href="../css/fileInput/fileinput.css" rel="stylesheet">  
    <script src="../js/jquery-3.3.1.min.js"></script>  
    <script src="../js/bootstrap/bootstrap.js"></script>  
    <script src="../js/fileInput/fileinput.js"></script>  
    <script src="../js/fileInput/locales/zh.js"></script>  
     <script src="../js/layer/layer.js"></script>
</head>  
<body>  
 <form id="uploadimg-form" style="padding-top: 3%;padding-left: 20%;width: 40%;">
      <input id="f_upload" type="file" class="file" data-show-preview="false"/>
      <a href="javascript:downExcel();" >下载模板</a>
</form>
  
  
    <script type="text/javascript">  
    
    function downExcel(){
    	var url = window.location.origin+"/ac/page/invest-template.xlsx";
    	window.open(url);
    }
    
     
    $('#f_upload').fileinput({
        language: 'zh', //设置语言
        uploadUrl: "/ac/importExcel", //上传的地址
        allowedFileExtensions : ['xls', 'xlsx'],//接收的文件后缀,
        maxFileCount: 1,
        enctype: 'multipart/form-data',
        uploadAsync: true, //默认异步上传
        showUpload: true, //是否显示上传按钮
        showCaption: true,//是否显示标题
        browseClass: "btn btn-primary", //按钮样式             
        previewFileIcon: "<i class='glyphicon glyphicon-king'></i>", 
        msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
        uploadExtraData:$('#uploadimg-form').serialize()
    });
    
    
  //异步上传返回结果处理
    $("#f_upload").on("fileuploaded", function (event, data, previewId, index) {
    	if(result.errno==302){
   		 	window.location.href="login.html";
   		}else{
   			if(data.errno=200){
    			layer.alert("导入成功");
    		}else{
    			layer.alert(data.errmsg);
    		}
   		}
           
      });
  
    //上传前
    $('#f_upload').on('filepreupload', function(event, data, previewId, index) {
       var form = data.form, files = data.files, extra = data.extra,
        response = data.response, reader = data.reader;
    });
        
    </script>  
</body>  
</html>  